package controllers.graph;

import edu.uci.ics.jung.algorithms.layout.SpringLayout;
import edu.uci.ics.jung.graph.DirectedGraph;
import edu.uci.ics.jung.graph.DirectedSparseGraph;
import play.mvc.Controller;

import java.awt.*;

public class TestController extends Controller {

    public static final int ITERATIONS = 100;
    public static final int LAYOUT_WIDTH = 800;
    public static final int LAYOUT_HEIGHT = 600;


    public static void spring() {
        DirectedGraph<String, String> graph = new DirectedSparseGraph<String, String>();

        String v1 = "v1";
        String v2 = "v2";
        String v3 = "v3";
        String v4 = "v4";
        String e12 = "e12";
        String e13 = "e13";
        String e23 = "e23";
        String e24 = "e24";

        graph.addEdge(e12, v1, v2);
        graph.addEdge(e13, v1, v3);
        graph.addEdge(e23, v2, v3);
        graph.addEdge(e24, v2, v4);

        SpringLayout layout = new SpringLayout(graph);

        layout.setSize(new Dimension(LAYOUT_WIDTH, LAYOUT_HEIGHT));

        for (int i = 0; i < ITERATIONS; i++) {
            layout.step();
        }

        System.out.println((int)layout.getX(v1)+":"+(int)layout.getY(v1));

        layout.done();

    }

    public static void svg(){
        render();
    }

    public static void geometry(){
        render();
    }


}
